package com.iversonx.observer.example_1.config;

import com.iversonx.observer.example_1.v2.EventManager;
import com.iversonx.observer.example_1.v2.listener.MQEventListener;
import com.iversonx.observer.example_1.v2.listener.SmsEventListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 *
 **/
@Configuration
public class EventManagerConfig {
    @Autowired
    private MQEventListener mqEventListener;
    @Autowired
    private SmsEventListener smsEventListener;
    @Bean
    public EventManager eventManager() {
        EventManager eventManager = new EventManager();
        eventManager.subscribe(EventManager.EventType.MQ, mqEventListener);
        eventManager.subscribe(EventManager.EventType.SMS, smsEventListener);
        return eventManager;
    }
}
